package com.molichuxing.services.business.convertor;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;

import com.molichuxing.services.business.dto.response.ComplaintBizDto;
import com.molichuxing.services.business.dto.response.DrivingLicenseBizDto;
import com.molichuxing.services.business.dto.response.UserBizDto;
import com.molichuxing.services.business.dto.response.UserDetailBizDto;
import com.molichuxing.services.infrastructure.dto.response.ComplaintDto;
import com.molichuxing.services.infrastructure.dto.response.DrivingLicenseDto;
import com.molichuxing.services.infrastructure.dto.response.UserDetailDto;
import com.molichuxing.services.infrastructure.dto.response.UserDto;

/**
 * 
 * @author liyg
 * 数据转换类
 * 2019-08-12
 * 
 */
public class Convert {

	public static UserBizDto toUserBizDto(UserDto dto) {
		UserBizDto beanDto = null;
		if (dto != null) {
			beanDto = new UserBizDto();
			BeanUtils.copyProperties(dto, beanDto);
		}
		return beanDto;
	}
	
	public static UserDetailBizDto toUserDetailBizDto(UserDto dto,UserDetailDto userDetail) {
		UserDetailBizDto beanDto = null;
		if (dto != null) {
			beanDto = new UserDetailBizDto();
			BeanUtils.copyProperties(dto, beanDto);
			beanDto.setRegionId(userDetail.getRegionId());
		}
		return beanDto;
	}
	
	public static List<DrivingLicenseBizDto> toDrivingLicenseBizDto(List<DrivingLicenseDto> beanList){
		List<DrivingLicenseBizDto> dtoList = null;;
		if (beanList != null && beanList.size() > 0) {
			dtoList = new ArrayList<>();
			for (DrivingLicenseDto drivingLicenseBeanDto : beanList) {
				dtoList.add(toDrivingLicenseBizDto(drivingLicenseBeanDto));
			}
		}
		
		return dtoList;
	}
	
	public static DrivingLicenseBizDto toDrivingLicenseBizDto(DrivingLicenseDto bean) {
		DrivingLicenseBizDto beanDto = null;
		if (bean != null) {
			beanDto = new DrivingLicenseBizDto();
			BeanUtils.copyProperties(bean, beanDto);
		}
		return beanDto;
	}
	
	
	public static List<ComplaintBizDto> toComplaintBizDto(List<ComplaintDto> beanList){
		List<ComplaintBizDto> dtoList = null;;
		if (beanList != null && beanList.size() > 0) {
			dtoList = new ArrayList<>();
			for (ComplaintDto complaintBeanDto : beanList) {
				dtoList.add(toComplaintBizDto(complaintBeanDto));
			}
		}
		
		return dtoList;
	}
	
	public static ComplaintBizDto toComplaintBizDto(ComplaintDto bean) {
		ComplaintBizDto beanDto = null;
		if (bean != null) {
			beanDto = new ComplaintBizDto();
			BeanUtils.copyProperties(bean, beanDto);
		}
		return beanDto;
	}
	
}
